<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <div style="padding-top: 1rem;"></div>
      <!-- table -->
      <FormPanel ref="formPanel" :list="formList1" :cols="3" :formType="'add'" labelWidth="110" :isSubmitBtn="false"  />
      <div style="padding-top: 1rem;"></div>
    </Spin>
    <div class="btns">
      <el-button type="primary" @click="saveDialog(1)">保 存</el-button>
      <el-button @click="closeDialog">关 闭</el-button>
    </div>

  </div>
</template>
<script>
import {dictionary} from'@/utils/dictMixin';
import { rejectCheck,auditPass } from '@/api/omSaleP/AutoBigOrderRefundAudit/index.js';
export default {
  mixins: [dictionary],
  components: {
    rejectCheck,
    auditPass
  },
  props: {
    rowData: {
      type: Object,
    },
    types: {
      type: Number,
      required: true
    },
  },
  data() {
    return {
      loading: false,
      dataList1: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      rowDate: {},
      infoId: null,
      flterValue: {}, //参数
      fetchParams: {}, //ipa 接口
      selectedRows: [],
      formList1: this.createFormList1(),
      saveData: null,
    };
  },
  mounted(){
    console.log('this.types',this.types)
    // if(this.types === 3){
    //   this.formList1.find(item => item.fieldName ==  'factoryAuditOpinion').rules = [{ required: false, message: '规则名称...', trigger: 'blur' }]
    // }
  },
  methods: {
    createFormList1() {
      return [
        {
          type: 'TEXT_AREA',
          label: '审核意见',
          selfCols: 3 ,
          rows:10,
          disabled: false,// 只读
          readonly: false,// 只读
          fieldName: 'factoryAuditOpinion',
          rules: [{ required: this.types === 3 ? false : true, message: '规则名称...', trigger: 'blur' }],
        }
      ];
    },
    async saveDialog(type) {
      let [err,data] = await this.$refs.formPanel.GET_FORM_DATA();
      data = Object.assign({},this.rowData,data);
      if (err)return;
       if (this.types == 3) {
        let res = await auditPass(data);
        if (res.resultCode == 200) {
          this.$notify.success({title: '提示信息', message: '审核通过提交成功!'});
          this.$emit('save', {type: 'refresh'});
        }
      } else if (this.types == 2) {
        let res = await rejectCheck(data);
        if (res.resultCode == 200) {
          this.$notify.success({title: '提示信息', message: '驳回提交成功!'});
          this.$emit('save', {type: 'refresh'});

        }
      }

    },
    closeDialog() {
      this.$emit('close', {visible: false, data: this.selectedRows, type: 'close'});
    }
  }
};
</script>

<style lang="less" scoped>
.btns{
  //overflow: hidden;
  //float: right;
  text-align: center;
}
</style>
